import { defineStore } from 'pinia'
import { RocketOutlined, HomeOutlined, SettingOutlined, DashboardOutlined, AppstoreOutlined, SolutionOutlined, SaveOutlined, ContainerOutlined, AuditOutlined, GiftOutlined } from '@vicons/antd'


interface FIconList {
    icons: FIcon[]
}

interface FIcon {
    name: string,
    icon: Object
}

export const useIconStore = defineStore('icon', {
    state: (): FIconList => ({
        icons: [{
            name: "setting-outlined",
            icon: SettingOutlined
        }, {
            name: "dashboard-outlined",
            icon: DashboardOutlined
        }, {
            name: "appstore-outlined",
            icon: AppstoreOutlined
        }, {
            name: "solution-outlined",
            icon: SolutionOutlined
        }, {
            name: "save-outlined",
            icon: SaveOutlined
        }, {
            name: "container-outlined",
            icon: ContainerOutlined
        }, {
            name: "audit-outlined",
            icon: AuditOutlined
        }, {
            name: "gift-outlined",
            icon: GiftOutlined
        }, {
            name: "home-outlined",
            icon: HomeOutlined
        }, {
            name: "rocket-outlined",
            icon: RocketOutlined
        }]
    }),
    getters: {
        icon: (state) => {
            return (name: string) => {
                if (name === null || name === "") {
                    return null
                }
                for (let i = 0; i < state.icons.length; i++) {
                    if (state.icons[i].name === name) {
                        return state.icons[i]
                    }
                }
                return null
            }
        },
        iconList: (state) => {
            return state.icons
        }
    }
})